import control  # pip install control
import matplotlib.pyplot as plt
import math
import numpy as np

TimeArray = [i*0.001 for i in range(5000)]
Ka = 6000
# sys = control.tf([1],[1/5000,1020/5000,20000/5000,0]) #open loop
sys = control.tf([5000*Ka],[1,1020,20000,5000*Ka]) #closed loop
 # 系统
TimeArray, yout = control.step_response(sys, TimeArray)

plt.title("Simulation")  # 括号当中输入标题的名称
plt.plot(TimeArray, yout, label="Ka=%d" % Ka)
plt.legend(loc='best')  # 图列位置，可选best，center等
plt.xlabel('Time(s)')
plt.ylabel('Output')
plt.show()
